package com.tidc.consumer8001.controller.score;

import com.tidc.commonality.api.TeacherScoreApi;
import com.tidc.commonality.ov.UserOV;
import com.tidc.commonality.pojo.Score;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassNmae TeacherScoreController
 * @Description TODO
 * @Author 冯涛滔
 **/
@RestController
@CrossOrigin
@RequestMapping
public class TeacherScoreController {
	@Autowired
	TeacherScoreApi teacherScoreApi;
	@ApiOperation("根据当前登录的老师id以及作品id来给作品评分，只需要分数以及比赛的id和作品id 如果返回500则是提醒该老师已经进行过评分了")
	@RequestMapping(value = "/teacher/score",method = RequestMethod.POST)
	public UserOV postScore(String token, Score score){
		return teacherScoreApi.postScore(token, score);
	}

	@ApiOperation("根据当前登录的老师id以及作品id来查看这个作品老师是否有进行过评分以及评了多少分,需要作品id")
	@RequestMapping(value = "/teacher/score/{id}",method = RequestMethod.GET)
	public UserOV getScore(String token, @PathVariable int id){
		return teacherScoreApi.getScore(token,id);
	}

	@ApiOperation("修改分数")
	@RequestMapping(value = "/teacher/score",method = RequestMethod.PUT)
	public UserOV setScore(String token, Score score){
		return teacherScoreApi.setScore(token,score);
	}
}
